package com.test.homwork3;

public class Printer {
    private int index = 1;

    public void print(int i) throws InterruptedException {
        if (index%3 == 0){
            wait();
            index--;
            System.out.print(i);
        }else {
            System.out.print(i);
            notifyAll();
        }
        index++;
    }

    public void print(char c) throws InterruptedException {
        if (index%3 != 0){
            wait();
            index--;
            System.out.print(c);
        }else {
            System.out.print(c);
            notifyAll();
        }
        index++;
    }
}
